package com.kitten.auth.controller;

import com.kitten.auth.model.vo.user.UpdatePasswordReqVO;
import com.kitten.auth.model.vo.user.UserLoginReqVO;
import com.kitten.auth.service.AuthService;
import com.kitten.framework.biz.operationlog.annotation.ApiOperationLog;
import com.kitten.framework.common.response.Response;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping
@Slf4j
public class AuthController {
    @Resource
    private AuthService authService;

    /**
     *
     * @param userLoginReqVO  -> phone(notNull), code, password, type(notNull)
     */
    @PostMapping("/login")
    @ApiOperationLog(description = "用户登录/注册")
    public Response<String> loginAndRegister(@Validated @RequestBody UserLoginReqVO userLoginReqVO) {
        return authService.loginAndRegister(userLoginReqVO);
    }

    /**
     * 用户修改密码
     * @param updatePasswordReqVO
     * @return
     */
    @PostMapping("/password/update")
    @ApiOperationLog(description = "修改密码")
    public Response<?> updatePassword(@Validated @RequestBody UpdatePasswordReqVO updatePasswordReqVO) {
        return authService.updatePassword(updatePasswordReqVO);
    }

    @PostMapping("/logout")
    @ApiOperationLog(description = "用户登出")
    public  Response<?> logout() {
        // TODO: 实现用户登出逻辑
        return authService.logout();
    }

}
